package com.wechat.utils;

import com.auth.model.wechat.Menu;
import com.auth.vo.wechat.MenuVo;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author:Tangjiachang
 * @Date 2023/7/29
 * @Description: 集合对象转化
 */
public class CollectionConvertUtils {
    /**
     * Menu集合转MenuVo集合
     *
     * @author Tangjiachang
     * @date 2023/7/29 13:14
     * @param menus:
     * @return List<MenuVo>
     **/
    public static List<MenuVo> menusToMenuVos(List<Menu> menus) {
        return menus.stream().map(CollectionConvertUtils::menuToMenuVo)
                .collect(Collectors.toList());
    }

    /**
     * Menu转MenuVo
     *
     * @author Tangjiachang
     * @date 2023/7/29 13:14
     * @param menu:
     * @return MenuVo
     **/
    public static MenuVo menuToMenuVo(Menu menu) {
        final MenuVo menuVo = new MenuVo();
        BeanUtils.copyProperties(menu, menuVo);
        return menuVo;
    }

}
